package com.ruoyi.web.controller.admin.faq;

import com.ruoyi.admin.domain.LlmFaq;
import com.ruoyi.admin.service.faq.LlmFaqService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/faq")
@RequiredArgsConstructor
public class LlmFaqController extends BaseController {

    private final LlmFaqService llmFaqService;

    /**
     * 新增
     */
    @PostMapping("/addFaq")
    public AjaxResult addFaq(@RequestBody LlmFaq llmfaq) {
        return llmFaqService.addFaq(llmfaq) ? AjaxResult.success() : AjaxResult.error();
    }

    /**
     * 根据ID删除
     */
    @DeleteMapping("/deleteFaq")
    public AjaxResult deleteFaq(@RequestParam("faqId") String faqId) {
        return llmFaqService.deleteLlmFaq(faqId) ? AjaxResult.success() : AjaxResult.error();
    }

    /**
     * 修改
     */
    @PutMapping("/editFaq")
    public AjaxResult editFaq(@RequestBody LlmFaq faq) {
        return llmFaqService.editFaq(faq) ? AjaxResult.success() : AjaxResult.error();
    }

    /**
     * 根据ID查询
     */
    @GetMapping("/{id}")
    public LlmFaq getFaqById(@PathVariable String id) {
        return llmFaqService.getFaqById(id);
    }

    /**
     * 查询所有
     */
    @GetMapping("/list")
    public TableDataInfo listAll() {
        startPage();
        return getDataTable(llmFaqService.list());
    }

    /**
     * 根据条件查询
     */
    @GetMapping("/getLlmFaq")
    public List<LlmFaq> getLlmFaq(LlmFaq llmFaq) {
        return llmFaqService.getLlmFaq(llmFaq);
    }
}
